package com.yjd.msg.comm.util;

import org.apache.log4j.Logger;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Created by yjd-wap on 2018/1/25.
 */
public class ThredPoolRejectedHandler implements RejectedExecutionHandler {
    private static Logger logger = Logger.getLogger(ThredPoolRejectedHandler.class);

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        if (!executor.isShutdown()) {
            try {
                executor.getQueue().put(r);
            } catch (InterruptedException e) {
                logger.error("线程池阻塞策略异常，异常信息:"+e);
            }
        }
    }
}
